package sh.ds.el.common;

import org.apache.struts2.ServletActionContext;

import sh.ds.el.entity.UserVO;

/**
 * 系统登录信息工具类
 * 
 * @author dongbz
 * @date 2012-9-25
 */
public class SecurityUtils {

	public static void keepCurrentUser(UserVO userVO) {
		ServletActionContext.getRequest().
			getSession().setAttribute(Constants.CURRENT_USER, userVO);
	}
	
	/**
	 * 获取当前登录用户
	 * 
	 * @return
	 */
	public static UserVO getCurrentUser() {
		return (UserVO) ServletActionContext.getRequest().
					getSession().getAttribute(Constants.CURRENT_USER);
	}
	
	/**
	 * 获取当前登录用户id
	 * 
	 * @return
	 */
	public static Long getCurrentUserId() {
		return getCurrentUser() != null ? getCurrentUser().getUserId() : null;
	}
	
}
